<!--  -->
<template>
    <div >
        <!-- <div class='table-page-search-wrapper'>
            <a-form layout='inline'>
               <a-row :gutter='48'>
                    <a-col :md='8' :sm='24'>
                        <a-form-item label="账户名称">
                            <a-input v-model="accountName" placeholder="请输入账户名称" allow-clear></a-input>
                        </a-form-item>
                    </a-col>
                    <a-col :md='8' :sm='24'>
                    </a-col>
                    <a-col :md='8' :sm='24'>
                        <a-form-item >
                            <a-button type='primary' @click="getData">查询</a-button>
                            <a-button style="margin-left: 20px" type='' @click="add">绑定账户</a-button>
                        </a-form-item>
                    </a-col>
                </a-row>
            </a-form>
        </div>   -->

        <a-table rowKey="id" :loading="isload" :columns="columns" :data-source="dataList" @change="handleTableChange" :pagination="{ 'total': total ,'showSizeChanger': true,'pageSize': size}" size="small" >
            <div slot="accountType" slot-scope="accountType">
                <div v-for="(item,i) in accountTypeList" :key="item.id">
                    <a-tag v-if="item.id == accountType" :color="colors[i%13]">{{item.name}}</a-tag>
                </div>
            </div>
            <div slot="linkageType" slot-scope="linkageType,record">
                <div v-for="(item,i) in linkageTypeList" :key="item.id">
                    <a-tag v-if="item.id == linkageType" :color="colors[i%13]">{{linkageType != 1 ? item.name : `${item.name}`}}<span v-if="linkageType == 1 && record.linkageAccounts">{{`，授权账户：${record.linkageAccounts[0].accountName}`}}</span></a-tag>
                </div>
            </div>
        </a-table>
    </div>
</template>

<script>
import { columns } from './table';
import { getCompanyAccount } from '@/api/companys/company';
export default {
    props: ['customerBusinessId'],
    data () {
        return {
            accountName: '', // 账户名称
            page: 1,
            size: 10,
            total: 0,
            dataList: [],
            isload: false,
            columns,
            visible: false,
            info: {
                accountId: '',
                channel: undefined,
                accountName: undefined,
                bankAccount: '',
            },
            rules: {
                accountName: [{ required: true, message: '请选择账户名称', trigger: 'blur' }],
                channel: [{ required: true, message: '请选择开户行', trigger: 'blur' }],
                bankAccount: [
                    { required: true, message: '暂无银行账户', trigger: 'blur' },
                ],
            },
            accountNameList: [], // 账户名称列表
            channelList: [], // 开户行列表
            accountTypeList: [
                { id: 1, name: '一般账户'},
                { id: 2, name: '基本账户'},
                { id: 3, name: '一般账户'},
                { id: 4, name: '一般账户'},
            ],
            linkageTypeList: [
                { id: 0, name: '未开通'},
                { id: 1, name: '发起方'},
                { id: 2, name: '授权方'},
            ],
        };
    },
    created(){
        this.getData();
    },
    methods: {
        // 获取列表数据
        getData(){
            let _this = this;
            _this.isload = true;
            const params = {
                'pageSize': _this.size,
                'pageIndex': _this.page,
                'customerBusinessId': _this.customerBusinessId,
            }
            getCompanyAccount(params)
            .then(res=>{
                _this.isload = false
                if(res.success){
                    _this.dataList = res.data;
                    // _this.total = res.totalCount;
                }else{
                    _this.$notification['error']({
                        message: '温馨提示',
                        description: res.errMessage,
                        duration: 8
                    })
                }
            })
        },
        // 分页
        handleTableChange(pagination, filters, sorter) {
            console.log(pagination);
            this.page = pagination.current;
            this.size = pagination.pageSize;
            this.getData()
        },
    }
}

</script>
<style scoped>

</style>